package com.jalarbee.core.spring.jpa;

import javax.sql.DataSource;

import org.apache.log4j.Logger;
import org.springframework.orm.jpa.persistenceunit.MutablePersistenceUnitInfo;
import org.springframework.orm.jpa.persistenceunit.PersistenceUnitPostProcessor;

/**
 * 
 * @author Abdoulaye Diallo
 *
 * Custom class to set the jtaDataSource
 */

public class CustomJtaPersistenceUnitPostProcessor implements PersistenceUnitPostProcessor {

	private DataSource jtaDataSource;
	
	private Logger logger = Logger.getLogger(CustomJtaPersistenceUnitPostProcessor.class);
	
	public void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo pui) {
		logger.info("Setting jtaDatasource...");
		pui.setJtaDataSource(jtaDataSource);
		
	}

	public void setJtaDataSource(DataSource jtaDataSource) {
		this.jtaDataSource = jtaDataSource;
	}

}
